<h1><code ng:non-bindable="">$routeProvider</code>
<span class="hint">(service in module <code ng:non-bindable="">ng</code>
)</span>
</h1>
<div><a href="http://github.com/angular/angular.js/edit/master/src/ng/route.js" class="improve-docs btn btn-primary">Improve
    this doc</a>

    <h2 id="Description">Description</h2>

    <div class="description">
        <div class="ng-routeprovider-page"><p>Used for configuring routes. See <a
                href="api/ng.$route"><code>$route</code></a> for an example.</p></div>
    </div>
    <div class="member method"><h2 id="Methods">Methods</h2>
        <ul class="methods">
            <li><h3 id="otherwise">otherwise(params)</h3>

                <div class="otherwise">
                    <div class="ng-routeprovider-otherwise-page"><p>Sets route definition that will be used on route
                        change when no other route definition
                        is matched.</p></div>
                    <h4 id="Parameters">Parameters</h4>
                    <ul class="parameters">
                        <li><code ng:non-bindable="">params – {Object} – </code>

                            <div class="ng-routeprovider-otherwise-page"><p>Mapping information to be assigned to <code>$route.current</code>.
                            </p></div>
                        </li>
                    </ul>
                    <h4 id="Returns">Returns</h4>

                    <div class="returns"><code ng:non-bindable="">{Object}</code>
                        –
                        <div class="ng-routeprovider-otherwise-page"><p>self</p></div>
                    </div>
                </div>
            </li>
            <li><h3 id="when">when(path, route)</h3>

                <div class="when">
                    <div class="ng-routeprovider-when-page"><p>Adds a new route definition to the <code>$route</code>
                        service.</p></div>
                    <h4 id="Parameters">Parameters</h4>
                    <ul class="parameters">
                        <li><code ng:non-bindable="">path – {string} – </code>

                            <div class="ng-routeprovider-when-page"><p>Route path (matched against
                                <code>$location.path</code>). If <code>$location.path</code>
                                contains redundant trailing slash or is missing one, the route will still match and the
                                <code>$location.path</code> will be updated to add or drop the trailing slash to exactly
                                match the
                                route definition.</p>

                                <p><code>path</code> can contain named groups starting with a colon (<code>:name</code>).
                                    All characters up to the
                                    next slash are matched and stored in <code>$routeParams</code> under the given
                                    <code>name</code> after the route
                                    is resolved.</p></div>
                        </li>
                        <li><code ng:non-bindable="">route – {Object} – </code>

                            <div class="ng-routeprovider-when-page"><p>Mapping information to be assigned to <code>$route.current</code>
                                on route
                                match.</p>

                                <p>Object properties:</p>

                                <ul>
                                    <li><code>controller</code> – <code>{(string|function()=}</code> – Controller fn
                                        that should be associated with newly
                                        created scope or the name of a <a href="api/angular.Module#controller"><code>registered
                                            controller</code></a>
                                        if passed as a string.
                                    </li>
                                    <li><code>template</code> – <code>{string=}</code> – html template as a string that
                                        should be used by
                                        <a href="api/ng.directive:ngView"><code>ngView</code></a> or
                                        <a href="api/ng.directive:ngInclude"><code>ngInclude</code></a> directives.
                                        this property takes precedence over <code>templateUrl</code>.
                                    </li>
                                    <li><code>templateUrl</code> – <code>{string=}</code> – path to an html template
                                        that should be used by
                                        <a href="api/ng.directive:ngView"><code>ngView</code></a>.
                                    </li>
                                    <li><p><code>resolve</code> - <code>{Object.&lt;string, function&gt;=}</code> - An
                                        optional map of dependencies which should
                                        be injected into the controller. If any of these dependencies are promises, they
                                        will be
                                        resolved and converted to a value before the controller is instantiated and the
                                        <code>$routeChangeSuccess</code> event is fired. The map object is:</p>

                                        <ul>
                                            <li><code>key</code> – <code>{string}</code>: a name of a dependency to be
                                                injected into the controller.
                                            </li>
                                            <li><code>factory</code> - <code>{string|function}</code>: If
                                                <code>string</code> then it is an alias for a service.
                                                Otherwise if function, then it is <a
                                                        href="api/AUTO.$injector#invoke"><code>injected</code></a>
                                                and the return value is treated as the dependency. If the result is a
                                                promise, it is resolved
                                                before its value is injected into the controller. Be aware that <code>ngRoute.$routeParams</code>
                                                will
                                                still refer to the previous route within these resolve functions. Use
                                                <code>$route.current.params</code>
                                                to access the new route parameters, instead.
                                            </li>
                                        </ul>
                                    </li>
                                    <li><p><code>redirectTo</code> – {(string|function())=} – value to update
                                        <a href="api/ng.$location"><code>$location</code></a> path with and trigger
                                        route redirection.</p>

                                        <p>If <code>redirectTo</code> is a function, it will be called with the
                                            following parameters:</p>

                                        <ul>
                                            <li><code>{Object.&lt;string&gt;}</code> - route parameters extracted from
                                                the current
                                                <code>$location.path()</code> by applying the current route templateUrl.
                                            </li>
                                            <li><code>{string}</code> - current <code>$location.path()</code></li>
                                            <li><code>{Object}</code> - current <code>$location.search()</code></li>
                                        </ul>

                                        <p>The custom <code>redirectTo</code> function is expected to return a string
                                            which will be used
                                            to update <code>$location.path()</code> and <code>$location.search()</code>.
                                        </p></li>
                                    <li><p><code>[reloadOnSearch=true]</code> - {boolean=} - reload route when only
                                        $location.search()
                                        changes.</p>

                                        <p>If the option is set to <code>false</code> and url in the browser changes,
                                            then
                                            <code>$routeUpdate</code> event is broadcasted on the root scope.</p></li>
                                </ul>
                            </div>
                        </li>
                    </ul>
                    <h4 id="Returns">Returns</h4>

                    <div class="returns"><code ng:non-bindable="">{Object}</code>
                        –
                        <div class="ng-routeprovider-when-page"><p>self</p></div>
                    </div>
                </div>
            </li>
        </ul>
    </div>
</div>
